package com.server.pinggu.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.server.common.utils.StringUtils;

/**
 * @Classname FengRui
 * @Description
 * @Date 2022-10-27 10:01
 */
public class Sex implements Converter<Long> {
    @Override
    public Class supportJavaTypeKey() {
        return null;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public Long convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String stringValue = cellData.getStringValue();
        if (StringUtils.isEmpty(stringValue)){
            return 0L;
        }
        if (stringValue.equals("男")){
            return 1L;
        }
        if (stringValue.equals("女")){
            return 2L;
        }else {
            return 0L;
        }
    }

    @Override
    public CellData convertToExcelData(Long s, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }
}
